<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
	<script>var ctx="${ctx}";</script>
	<head>
	    <meta charset="utf-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <title>商品管理</title>
	    <meta name="keywords" content="体验,友好,高级管理台,易用,高性能,高扩展性,bootstrap框架,响应式后台">
	    <meta name="description" content="这是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
	    <meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
		<meta http-equiv="expires" content="Wed, 26 Feb 209908:21:57 GMT"> 
	    
		<link rel="shortcut icon" href="favicon.ico"> 
		<link href="${ctx}/static/css/bootstrap.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/font-awesome.min.css?v=4.4.0?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/footable/footable.core.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/summernote/summernote-bs3.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/plugins/laypage/laypage.css?v=${static_version}"  rel="stylesheet">
		<link href="${ctx}/static/css/plugins/iCheck/custom.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/chosen/chosen.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/animate.min.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/js/plugins/layer/laydate/laydate.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/plugins/webuploader/webuploader.css?v=${static_version}/" rel="stylesheet">
		<link href="${ctx}/static/css/style.min.css?v=${static_version}/" rel="stylesheet">
	    
	</head>
	<body class="gray-bg">
    	<div class="ibox float-e-margins">
    		<div class="ibox-content">
                <form class="form-group" id="goods_table_form">	
                	<input type="hidden" name="merchantId" value="${merchantId }">
                	<input type="hidden" name="saleId" value="${saleId }">
                	<input type="hidden" name="catId" value="${catId }">
                	<div class="row">
						<perm:hasPermission code="goods/insertGet">
					    <div class="col-md-2  col-sm-2">
							<a  onclick="clickInsertGet()" class="btn btn-block btn-outline btn-primary">添加选中</a>
					    </div>
					    </perm:hasPermission>
					    <div class="col-md-2"><input name="keyword" type="text" placeholder="请输入关键字" class="form-control" /></div>
						<div class="col-md-1 col-sm-2">
							<button id="goods_table_search" type="button" class="btn btn-outline btn-block btn-primary">查询</button>
						</div>
                    </div>
                </form>
				<table id="goods_table" data-action="${ctx}/sale/selectList" data-datatable="true"  class="footable table table-stripped toggle-arrow-tiny">
				  	<thead>
					  	<tr>
					  		<th data-sort-ignore="true"  data-title="id" data-hide="phone,tablet" data-type="callback" data-callback="initCheckbox" ><input type="checkbox" name="input"></th>
					  		<th data-sort-ignore="true"  data-title="sn" >编号</th>				
							<th data-sort-ignore="true"  data-title="name" >名称</th>
							<th data-sort-ignore="true"  data-title="sale_price">特卖价</th>
							<th data-sort-ignore="true"  data-title="price">价格</th>
							<th data-sort-ignore="true"  data-title="catName" >分类</th>
							<th data-sort-ignore="true"  data-title="brandName" >品牌</th>
							<th data-sort-ignore="true"  data-title="status"  data-type="enum" data-opt='{"0":"是","1":"否"}'>上架</th>
							<th data-sort-ignore="true"  data-title="createDate" data-type="datetime" data-hide="phone,tablet">上架时间</th>
					  	</tr>
				  	</thead>
				  	<tbody>
				  	</tbody>
			  	</table>
			  	<div class="row">
			  		<div class="col-md-6" class="pull-left" id="page_left_text"></div>
			  		<div class="col-md-6"  id="page_text"></div>
			  	</div>
			</div>
		</div>
		
	<script src="${ctx}/static/js/jquery.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/bootstrap.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/footable/footable.all.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/jquery.validate.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/validate/messages_zh.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/webuploader/webuploader.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/summernote/summernote-zh-CN.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/chosen/chosen.jquery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/layer/laydate/laydate.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/iCheck/icheck.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/plugins/laypage/laypage.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/plugins/switchery/switchery.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/eModal.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/cookie.js?v=?v=${static_version}"></script>
	<script src="${ctx}/static/common/custom-datatable.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/content.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/js/contabs.min.js?v=${static_version}"></script>
	<script src="${ctx}/static/common/common.js?v=${static_version}"></script>
	
	<script>
		$(document).ready(function() {
			init_page_datatable();
		});
	
		var initCheckbox=function(cData,cLable,row){
			return '<input type="checkbox" value="'+cData+'" name="input[]">';
		}
		
		var clickInsertGet=function(){
			var saleGoods = new Array();
			if($("[name='input[]']").filter(':checked').length>0){
				$("[name='input[]']").filter(':checked').each(function(){
					saleGoods.push({saleId: "${saleId}", goodsId: $(this).attr("value")});
				  })
    			$.ajax({  
    				url:'${ctx}/sale/joinAdd',  		 					
    				type: 'POST',
    				data: JSON.stringify(saleGoods),
    				dataType: "json",
    				contentType: "application/json",
    				success: function(data){
    					if(data.code==0){
    						alert("添加成功");
    						init_page_datatable();
    			    	}else {
    						alert("添加失败");
    			    	}
    				}
    		     });
        	}else{
        		alert("请选择商品");
        	}
		}
	</script>
	
	</body>
</html>